<template>
  <!-- 面包屑 -->
  <Breadcrumb />
  <el-table :data="tableData" style="width: 100%">
    <el-table-column prop="id" label="id" width="180" />
    <el-table-column prop="number" label="订单编号" width="180" />
    <el-table-column prop="time" label="退货时间" width="180" />
    <el-table-column prop="name" label="购买人" width="180" />
    <el-table-column prop="price" label="订单总价格" width="180" />
    <el-table-column prop="status" label="订单状态" width="180" />
    <el-table-column label="操作">
      <template #default="scope">
        <el-button
          size="small"
          link
          type="primary"
          @click="handleEdit(scope.$index, scope.row)"
        >
          修改状态
        </el-button>
      </template>
    </el-table-column>
  </el-table>
  <!-- 对话弹框 -->
  <el-dialog
    v-model="flag"
    :title="flags ? '修改状态' : '编辑广告位'"
    :show-close="false"
    width="800"
  >
    <el-form
      style="max-width: 600px"
      :model="forms"
      label-width="auto"
      class="demo-ruleForm"
      :size="formSize"
      status-icon
    >
      <el-form-item label="位置类型" prop="region">
        <el-select v-model="forms.status" placeholder="">
          <el-option label="待处理" value="待处理" />
          <el-option label="已完成" value="已完成" />
        </el-select>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="updateForm(ruleFormRef)">
          确定
        </el-button>
        <el-button @click="resetForm(ruleFormRef)">取消</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script setup >
import { ref, reactive, toRefs, onMounted } from "vue";
import Breadcrumb from "../../components/bread/Breadcrumb.vue";
const flag = ref(false); //控制弹窗显隐
const flags = ref(true); //控制添加、修改
const forms = ref({
  status:''
})
// 点击编辑按钮
const handleEdit = (index, row) => {
  flag.value = true; //控制弹窗显示
  // 回显数据
  forms.value = row;
};
// 编辑弹窗确定
const updateForm = async (formEl) => {
  flag.value = false; //控制弹窗隐藏
  console.log(forms.value);
};
// 添加/编辑弹窗取消
const resetForm = (formEl) => {
  flag.value = false; //控制弹窗隐藏
};
const tableData = [
  {
    id: 1,
    number: "tb2023110609325445",
    time: "2024-05-07 11:00",
    name: "林俊杰",
    price: "1200",
    status: "待处理",
  },
  {
    id: 2,
    number: "tb2023110609325445",
    time: "2024-05-07 11:00",
    name: "陈奕迅",
    price: "1200",
    status: "已完成",
  },
  {
    id: 3,
    number: "tb2023110609325445",
    time: "2024-05-07 11:00",
    name: "周杰伦",
    price: "1200",
    status: "已完成",
  },
];
</script>
<style scoped lang="less">
</style>